package com.itheima;

import com.itheima.config.SpringConfig;
import com.itheima.domain.Account;
import com.itheima.service.AccountService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class App {

    public static void main(String[] args) {
        //1. 获取核心容器对象
        ApplicationContext app = new AnnotationConfigApplicationContext(SpringConfig.class);
        //2. 获取Service
        AccountService service = (AccountService) app.getBean("accountService");

        System.out.println(service.findById(1));

        System.out.println("================================================");

        List<Account> list = service.findAll();
        for (Account account : list) {
            System.out.println(account);
        }

    }
}
